<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-bottom: 20px">
      <el-breadcrumb-item :to="{ path: '/backstage/index' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>个人信息(展示)</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片信息 -->
    <el-card shadow="hover">
      <el-descriptions class="margin-top" :title="currentLoginName" :column="3" direction="vertical">
        <template slot="extra">
          <el-button type="primary" size="small" @click="toPersonalEditPageFunc">修改</el-button>
        </template>
        <el-descriptions-item label="头像">
          <el-avatar shape="square" :size="80" fit="fill" :src="userAvatarUrl"></el-avatar>
        </el-descriptions-item>
        <el-descriptions-item label="账号">{{account}}</el-descriptions-item>
        <el-descriptions-item label="性别" v-if="userSex != ''">
          <el-tag size="small">{{userSex}}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="联系电话">{{loginPhone}}</el-descriptions-item>
        <el-descriptions-item label="联系地址">{{address}}</el-descriptions-item>
        <el-descriptions-item label="企业联系人" v-if="leader != ''">{{leader}}</el-descriptions-item>
        <el-descriptions-item label="邮箱">{{email}}</el-descriptions-item>
        <el-descriptions-item label="身份证" v-if="idNumber != ''">{{idNumber}}</el-descriptions-item>
        <el-descriptions-item label="婚姻状态" v-if="userIsMarried != ''">
          <el-tag size="small">{{userIsMarried}}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="备注">
          <el-tag size="small">{{remarks}}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="注册时间">{{userRegisterDate}}</el-descriptions-item>
      </el-descriptions>
    </el-card>
  </div>
</template>

<script>
import { getCompanyOrUserAllInfo } from "../../../api/personalApi/index";
import { getStore } from '../../../storage/storage';
export default {
  name: "ViewInfo",
  data() {
    return {
      // 默认头像
      currentLoginName: '',
      userAvatarUrl:'https://recruitment-files.oss-cn-chengdu.aliyuncs.com/user1647687372000.jpg',
      loginPhone:'',
      address: '',
      email: '',
      idNumber:'',
      account: '',
      leader: '',
      remarks: '',
      userIsMarried: '',
      userSex: '',
      userRegisterDate: '',
    };
  },
  created(){
    // 获取当前登陆的全部信息
    this.getCurrentLoginAllInfoFunc();
  },
  methods:{
    // 获取当前登陆的全部信息
    getCurrentLoginAllInfoFunc(){
      const params = {
        account: getStore("account"),
      }
      getCompanyOrUserAllInfo(params).then(res=>{
        this.userRegisterDate = res.data.data.userRegisterDate ? res.data.data.userRegisterDate : res.data.data.companyRegisterDate;
        this.userSex = res.data.data.userSex ? res.data.data.userSex : '';
        this.userIsMarried = res.data.data.userIsMarried ? res.data.data.userIsMarried : '';
        this.remarks = res.data.data.remarks;
        this.leader = res.data.data.companyLeader ? res.data.data.companyLeader : '';
        this.account = res.data.data.userAccount ? res.data.data.userAccount : res.data.data.companyAccount;
        this.idNumber = res.data.data.userIdNumber ? res.data.data.userIdNumber : '';
        this.email = res.data.data.userEmail ? res.data.data.userEmail : res.data.data.companyEmail;
        this.address = res.data.data.userAddress ? res.data.data.userAddress : res.data.data.companyAddress;
        this.loginPhone = res.data.data.userPhone ? res.data.data.userPhone : res.data.data.companyPhone;
        this.userAvatarUrl = res.data.data.avatar ? res.data.data.avatar : 'https://recruitment-files.oss-cn-chengdu.aliyuncs.com/user1647687372000.jpg';
        this.currentLoginName = res.data.data.userName ? res.data.data.userName : res.data.data.companyName;
      })
    },

    // 去修改页面
    toPersonalEditPageFunc(){
      this.$router.push("/backstage/personal/editInfo");
    }

  }
 
}
</script>

<style scoped>

</style>